package com.okami.java8.generic.erasure;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: TanJingyu
 * @create: 2020-10-09 10:58
 **/
public class Erased<T> {
    private final int SIZE = 100;

//    public void f(Object arg) {
//        // error: illegal generic type for instanceof
//        if (arg instanceof T) {
//        }
//        // error: unexpected type
//        T var = new T();
//        // error: generic array creation
//        T[] array = new T[SIZE];
//        // warning: [unchecked] unchecked cast
//        T[] array2 = (T[]) new Object[SIZE];
//
//    }
    public static void main(String[] args) {
        Erased<String> erased = new Erased<>();
        System.out.println(erased.create());
    }

    T[] show() {
        return (T[])Array.newInstance(String.class, 10);
    }

    List<T> create() {
        return new ArrayList<>();
    }
}

